<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateActivityPrizesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_prizes', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('activity_id')->unsigned()->comment('抽奖活动ID');
            $table->foreign('activity_id')->references('id')->on('activities')->onDelete('cascade');
            $table->tinyInteger('level')->comment('奖品等级：1-一等奖、2-二等奖、3-三等奖、4-四等奖、5-五等奖、6-六等奖');
            $table->string('name')->comment('奖品名字');
            $table->text('description')->comment('描述');
            $table->string('image')->comment('图片');
            $table->string('little_image')->nullable()->comment('小图');
            $table->decimal('probability', 8, 4)->default(0)->comment('中奖概率(单位：%)');
            $table->integer('stock')->unsigned()->comment('奖品库存');
            $table->integer('order')->unsigned()->default(0)->comment('排序');
            $table->boolean('valid')->default(TRUE)->comment('是否有效');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activity_prizes');
    }
}
